'''
需要创建一个动作链对象 ActionChains(driver)
perform()执行
'''

import time
from time import sleep

from selenium import webdriver
from selenium.webdriver import ActionChains, Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
driver = webdriver.Edge()
driver.get("http://www.sogou.com")
time.sleep(3)
#创建动作链对象
a=ActionChains(driver)
#获取拖动标签
a1 = driver.find_element(By.PARTIAL_LINK_TEXT,"图片")
#获取文本框标签
a2=driver.find_element(By.ID,"query")
#动作链对象进行拖动动作，并执行
a.drag_and_drop(a1,a2).perform()
#回车
a.send_keys(Keys.ENTER).perform()
time.sleep(2)